<?php
namespace Systemht\Model;
use Think\Model;
class LinkModel extends Model{
	protected $insertField = array('name','link');
	protected $updateField = array('id','name','link');
	protected $_validate = array(
		array('name','require','连接名称不能为空'),
		array('link','require','连接地址不能为空'),
		);
	protected function _before_insert(&$data,$option){
		$data['ctime'] = time();
		if(isset($_FILES['image']) && $_FILES['image']['error'] == 0){
            $data['image'] = uploadImage('image');
        }
	}
	protected function _before_update(&$data,$option){
		if(isset($_FILES['image']) && $_FILES['image']['error'] == 0){
            $data['image'] = uploadImage('image');
            delImage(I('post.old_image'));
        }
	}
}